﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WorldOnFire
{
    public class CRelay : ABCProjectile
    {
        private int[] m_nRelayIndex;

        public override void Initialize(int _nObjectCount)
        {
            // Initialize the arrays
            m_nRelayIndex = new int[_nObjectCount];

            // Initialize the base members
            base.Initialize(_nObjectCount);

            // Set the enumerations
            eBaseType[] eBaseTypes = new eBaseType[] { eBaseType.MOVING_OBJECT, eBaseType.PROJECTILE };
            this.SetBaseTypeID(eBaseTypes);

            this.SetObjectType(eObjectType.PROJECTILE_RELAY);
            this.SetProjectileID(eProjectileType.RELAY);

            // Assign collidable types
            m_CollidableTypeList.Add(eObjectType.ENEMY_BOMBER);
            m_CollidableTypeList.Add(eObjectType.ENEMY_DETONATOR);
            m_CollidableTypeList.Add(eObjectType.ENEMY_GUARDIAN);
            m_CollidableTypeList.Add(eObjectType.ENEMY_DESTROYER);
            m_CollidableTypeList.Add(eObjectType.ENEMY_CRUISER);
            m_CollidableTypeList.Add(eObjectType.ENEMY_BATTLESHIP);
            m_CollidableTypeList.Add(eObjectType.ENEMY_CARRIER);
            m_CollidableTypeList.Add(eObjectType.ENEMY_JUGGERNAUT);
        }

        protected override void InitializeProjectile(int _nProjectileIndex, ABCTurret _Turret, int _nTurretIndex, Vector3 _vOffset)
        {
            // Initialize the base members
            base.InitializeProjectile(_nProjectileIndex, _Turret, _nTurretIndex, _vOffset);

            // TODO: Cast as relay, get index
        }

        protected override void KillProjectile(int _nProjectileIndex)
        {
            // Set the projectile to inactive
            base.KillProjectile(_nProjectileIndex);

            // Create a relay
            SEventSystem.SendEvent( new CEventObjectRelay(
                m_mTransform[_nProjectileIndex].Translation,
                m_fRadius[_nProjectileIndex],
                m_nRelayIndex[_nProjectileIndex]));
        }
    }
}
